<!--
 * @Descripttion: 
 * @Author: YuZhenJing
 * @Date: 2020-07-12 10:56:25
 * @LastEditors: YuZhenJing
 * @LastEditTime: 2020-07-17 16:30:34
-->
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>js 复杂对象解构</title>
  </head>
  <body>
    <script>
      let user = {
        name: "ay",
        age: "1",
        leason: {
          title: "java",
        },
      };
      let {
        name,
        leason: { title },
      } = user;
      console.log(name, title);
      console.log(JSON.stringify(user, null, 2));

      function test() {
        let oldDiv = document.body.querySelector("div");
        if (oldDiv) {
          document.body.removeChild(oldDiv);
        }
      }

      function sum(...ages) {
        ages.reduce((a, b) => {
          console.log(a, b);
          return a + b;
        });
      }
      sum(12, 13, 11, 15, 16);

      let obj = {
        nameobj: "test",
        ageobj: 12,
        good: true,
      };
      let testaaa = [11, 22, 33];
      let [a, b] = [...testaaa];
      let { nameobj, ...newObj } = { ...obj };
      console.log(newObj);
    </script>
  </body>
</html>
